package com.tsunami.message.controller;

import com.tsunami.message.entity.Message;
import com.tsunami.message.service.mq.MqttGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lx
 * @date 2024-09-21
 */
@RestController
@RequiredArgsConstructor
public class MqttPublishController {
    private final MqttGateway mqttGateway;

    @PostMapping("/send")
    public String send(Message message){
        mqttGateway.sendToMqtt(message.getTopic(),message.getContent());
        return "send topic: " + message.getTopic() + ", message : " + message.getContent();
    }
}
